package com.deepexp.servicetest.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.deepexp.servicetest.R;
import com.deepexp.servicetest.adapter.baseadapter.SimpleRecAdapter;
import com.deepexp.servicetest.entity.Account;

import java.util.List;
import java.util.Map;

/**
 * Author xyh
 * create time 2021/2/4
 */
public class AccountAdapter extends SimpleRecAdapter<Account, AccountAdapter.ViewHolder> {


    public AccountAdapter(Context context) {
        super(context);
    }

    @Override
    public void onBindViewHolder(ViewHolder viewHolder, int i) {
        Account account = data.get(i);
        if (account != null) {
            viewHolder.tvName.setText("名称:"+((account.getNickname() == null || account.getNickname().equals("")) ? "未设置" : account.getNickname()));
            viewHolder.tvRegister.setText("时间:"+account.getRegtime());
            viewHolder.tvPhoneNum.setText("手机:"+account.getMobilenum());
        }
    }

    @Override
    public ViewHolder newViewHolder(View itemView) {
        return new ViewHolder(itemView);
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_accountinfo;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {

        TextView tvName;
        TextView tvRegister;
        TextView tvPhoneNum;

        public ViewHolder(View itemView) {
            super(itemView);
            tvName = itemView.findViewById(R.id.tv_Name);
            tvRegister = itemView.findViewById(R.id.tv_Register);
            tvPhoneNum = itemView.findViewById(R.id.tv_PhoneNum);
        }

    }
}
